package com.woniuxy.woniubook.mapper;

import com.woniuxy.woniubook.entity.Book;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author wugd
 * @since 2022-11-16 02:13:11
 */
@Mapper
public interface BookMapper extends BaseMapper<Book> {

    @Update("update t_book set buycount = buycount+#{bcount} where id = #{bid}")
    int updateBuyCount(@Param("bid") Long bid, @Param("bcount") int bcount);

    @Update("update t_book set storecount = storecount-#{bcount} where id = #{bid} and storecount >= #{bcount}")
    int updateStoreCount(@Param("bid") Long bid, @Param("bcount") int bcount) ;

}
